package movingbox;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JFrame;

public class MovingBox{
	
	static JFrame jf;
	static BoxContainer bc;
	
	static int currentItem;
	static int beforeCurrentItem;
	static int wishItem;
	
	static Point startP;
	static Point currentP;
	
	static Dimension currentD;
	static Dimension restD;
	static Dimension spaceD;

	static List<PacketBox> boxes;
	
	public static ImageIcon getImageIcon(String path){
		return new ImageIcon(jf.getClass().getResource(path));
	}
	
	public static ImageIcon scaleImageIcon(ImageIcon icon, int width, int height){
		Image img = icon.getImage();
		
		Image newimg = img.getScaledInstance(width, height, java.awt.Image.SCALE_SMOOTH);
		
		icon = new ImageIcon(newimg);

		return icon;
	}
	
	public static void removeBoxBorder(PacketBox box){
		box.setBorderPainted(false);
		box.setContentAreaFilled(false);
		box.setDefaultCapable(false);
		box.setFocusPainted(false);
	}
	
	public static void main(String[] args) {
		
		currentItem = 0;
		beforeCurrentItem = 0;
		wishItem = 0;
		
		currentD = new Dimension(170, 170);
		restD = new Dimension(85, 85);
		spaceD = new Dimension(427, 2);
		
		boxes = new ArrayList<PacketBox>();
		
		
		jf = new JFrame();
		
		jf.setBackground(Color.white);
		jf.setPreferredSize(new Dimension(1024, 500));
		jf.setLocation(100, 100);
		jf.setUndecorated(true);
		
		startP = new Point(spaceD.width, spaceD.height + (currentD.height - restD.height));
		currentP = new Point(jf.getSize().width/2 - currentD.width/2, spaceD.height);
		
		jf.setLayout(null);
		
		bc = new BoxContainer(boxes);
		
		//bc.setSize(new Dimension(jf.getSize().width, 300));
		//bc.setLocation(0, 300);
		
		jf.getContentPane().add(bc);
		
		bc.setBounds(0, 326, 1024, 194);
		
		bc.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
		
		bc.t.start();
		
		jf.pack();
		
		jf.setVisible(true);
		
	}

}
